package lib

import (
	"bufio"
	"goloader"
)

// Ptrbufio 设置bufio库指针
func Ptrbufio(symPtr map[string]uintptr) {
	// 注册函数
	goloader.RegFunc(symPtr, "bufio.ScanLines", bufio.ScanLines)
	goloader.RegFunc(symPtr, "bufio.ScanBytes", bufio.ScanBytes)
	goloader.RegFunc(symPtr, "bufio.ScanRunes", bufio.ScanRunes)
	goloader.RegFunc(symPtr, "bufio.ScanWords", bufio.ScanWords)
	goloader.RegFunc(symPtr, "bufio.NewReader", bufio.NewReader)
	goloader.RegFunc(symPtr, "bufio.NewReaderSize", bufio.NewReaderSize)
	goloader.RegFunc(symPtr, "bufio.NewReadWriter", bufio.NewReadWriter)
	goloader.RegFunc(symPtr, "bufio.NewScanner", bufio.NewScanner)
	goloader.RegFunc(symPtr, "bufio.NewWriter", bufio.NewWriter)
	goloader.RegFunc(symPtr, "bufio.NewWriterSize", bufio.NewWriterSize)
	// 注册类型
	goloader.RegTypes(symPtr, &bufio.ReadWriter{})
	PReader := new(bufio.Reader)
	goloader.RegTypes(symPtr, PReader,
		PReader.Buffered,
		PReader.Discard,
		PReader.Peek,
		PReader.Read,
		PReader.ReadByte,
		PReader.ReadBytes,
		PReader.ReadLine,
		PReader.ReadRune,
		PReader.ReadSlice,
		PReader.ReadString,
		PReader.Reset,
		PReader.Size,
		PReader.UnreadByte,
		PReader.UnreadRune,
		PReader.WriteTo,
	)
	pScanner := new(bufio.Scanner)
	goloader.RegTypes(symPtr, pScanner,
		pScanner.Buffer,
		pScanner.Bytes,
		pScanner.Err,
		pScanner.Scan,
		pScanner.Split,
		pScanner.Text,
	)
	goloader.RegTypes(symPtr, new(bufio.SplitFunc))
	pWriter := new(bufio.Writer)
	goloader.RegTypes(symPtr, pWriter,
		pWriter.Available,
		pWriter.Buffered,
		pWriter.Flush,
		pWriter.ReadFrom,
		pWriter.Reset,
		pWriter.Size,
		pWriter.Write,
		pWriter.WriteByte,
		pWriter.WriteRune,
		pWriter.WriteString,
	)
}
